﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using QiAdmin.Core.Models;

namespace QiAdmin.Core
{
    public static class App
    {
        public static IConfiguration Configuration { get; set; }
        public static IServiceProvider Instance { get; set; }

        /// <summary>
        /// 获取服务
        /// 最好只获取单例注入的服务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T? GetService<T>() => Instance.GetService<T>();

        public static IHostEnvironment Environment => Instance.GetRequiredService<IHostEnvironment>();

        public static AppData AppSettings { get; set; }

        public static StaticData StaticData { get; }=new StaticData();
    }
}
